package com.example.rabbitmqtest01.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {

    private static  final String FANOUT_QUEUE="fanout_queue";
    private static  final String FANOUT_EXCHANGE="fanout_exchange";

    /**
     * 队列
     * @return
     */
    @Bean
    public Queue fanout01 (){
        return QueueBuilder.nonDurable(FANOUT_QUEUE+"_01").build();
    }
    @Bean
    public Queue fanout02 (){
        return QueueBuilder.nonDurable(FANOUT_QUEUE+"_02").build();
    }
    @Bean
    public Queue fanout03 (){
        return QueueBuilder.nonDurable(FANOUT_QUEUE+"_03").build();
    }
    /**
     * 交换机
     */
    @Bean
    public FanoutExchange fanoutExchange(){
        return ExchangeBuilder.fanoutExchange(FANOUT_EXCHANGE).build();
    }
    /**
     * 绑定关系
     */
    @Bean
    public Binding fanoutBind01(){
        return BindingBuilder.bind(this.fanout01()).to(this.fanoutExchange());
    }
    @Bean
    public Binding fanoutBind02(){
        return BindingBuilder.bind(this.fanout02()).to(this.fanoutExchange());
    }
    @Bean
    public Binding fanoutBind03(){
        return BindingBuilder.bind(this.fanout03()).to(this.fanoutExchange());
    }
}
